import React from 'react'
import * as action from "../action/index.js"
import {useEffect} from "react"
import {useSelector,useDispatch} from "react-redux"
console.log(action,11111)
function App() {
  let appreducerstore = useSelector((state)=>{
    console.log(state,"state");
    return {
      ...state.appreducer
    }
  })
  let bppreducerstore = useSelector((state)=>{
    console.log(state,"state");
    return {
      ...state.brrreducer
    }
  })
  useEffect(()=>{
    // 组件中去调用action的方法
    dispatch(action.getcarlist())
    // action下写这个方法
  },[])
  let dispatch = useDispatch()
  let fn = ()=>{
    dispatch(action.setAge())
  }
  let fn1 = ()=>{
    // 组件要想和仓库通信 三步走
    // 1. 组件调用action下的方法
    // 2, 去ation下写这个方法
    // 3. 去对应的reducer中去执行对应的操作
    dispatch(action.setAddress())
  }
  console.log(appreducerstore,bppreducerstore);
  return (
    <div>
      {
         appreducerstore.arr &&  appreducerstore.arr.length?   appreducerstore.arr.map((item,index)=>{
           return <div key={index}>
             {
               item.Name
             }
           </div>
         }):"暂无数据"
      }
        

    </div>
  )
}

export default App